package com.atguigu.chaptar7

object $07_MatchTuple {
  def main(args: Array[String]): Unit = {
    val tuple:(Any,Any,Any) = ("zhangsan", 20, "shenzhen")
    tuple match {
        //匹配元组时变量是几元元组,匹配的条件就应该匹配几元元组,否则报错
      case (name:String,age:Int,address:Int)=>{println(name,age,address)}//匹配类型
      case (name,age,address)=>{println(name,age,address)}
    }
    //元组工作中模式匹配应用场景:使用模式匹配使得代码可读性高
    val regions = List(
      ( "宝安区",( "宝安中学", ("大数据班", ( "zhangsan",30 )) ) ),
      ( "宝安区",( "宝安中学", ("大数据班", ( "lisi",30 )) ) ),
      ( "宝安区",( "宝安中学", ("大数据班", ( "wangwu",30 )) ) )
    )
    regions.foreach(x=>{
      x match {
        case (regionName,(regionSchool,(className,(stuName,age))))=>{
          println(stuName)
        }
      }
    })
  }

}
